import { useDispatch, useSelector } from 'react-redux';
import { add, minus } from './App';
import { add11, minus11 } from './App';
export function Counter() {
  const count = useSelector((state: any) => {
    console.log(state, 'state');
    return state.counter; // 访问 counter slice 的状态
  });
  const count11 = useSelector((state: any) => {
    console.log(state, 'state');
    return state.counter11; // 访问 counter slice 的状态
  });
  console.log(count, 'count');
  const dispatch = useDispatch();
  return (
    <div>
      <button onClick={() => dispatch(add())}>add 1</button>
      <button onClick={() => dispatch(minus())}>minus 1</button>
      <button
        onClick={() => {
          setTimeout(() => {}, 1000);
        }}
      >
        async add 10
      </button>
      <p>count is {count}</p>
      <button onClick={() => dispatch(add11())}>add 1</button>
      <button onClick={() => dispatch(minus11())}>minus 1</button>

      <p>count is {count11}</p>
    </div>
  );
}
